{literal}
	<script type="text/javascript">
		$(document).ready(function(){
			var col = "{/literal}{$orderby}{literal}";
			var order = "{/literal}{$order}{literal}";
			$(".sortImage").attr("src","images/sort_both.png");
			if (order=="desc")
		 		$("#sort"+col).attr("src","images/sort_desc.png");
		 	else if (order=="asc")
		 		$("#sort"+col).attr("src","images/sort_asc.png");
		})		 
	</script>
{/literal}

<div class="grid_10" >
	<div class="box round first grid">
    	<h2>Registro de delitos</h2>
      	<div class="clear"></div>
      	
      	<!-- Opciones generales -->
		<div style="padding-top:10px">
			{if $rol|strpos:"0" !== false || ($rol|strpos:"Ew" !== false && $seccional == 1) || ($rol|strpos:"Pw" !== false && $seccional == 2) || ($rol|strpos:"Mw" !== false && $seccional == 3) || ($rol|strpos:"Cw" !== false && $seccional == 4) }
				<a style="margin-right:20px" href="delitos.php?action=add&s={$seccional}"><img width="33px" src="images/new.png" alt="Nuevo delito" title="Nuevo delito"/></a>
			{/if}
		    <a style="margin-right:20px" href="delitos.php?action=stats&s={$seccional}"><img width="33px" src="images/stats.png" alt="Estad&iacute;sticas" title="Estad&iacute;sticas"/></a>
			<a style="margin-right:20px" href="delitos.php?action=map&s={$seccional}"><img width="33px" src="images/maps.png" alt="Mapa de delitos" title="Mapa de delitos"/></a>
			<a style="margin-right:20px" href="delitos.php?action=heatmap&s={$seccional}"><img width="33px" src="images/heatmap.png" alt="Mapa de calor" title="Mapa de calor"/></a>
		</div>
		<br><div class="clear"></div>
		
     	<div class="block">
     		{include file="delitosSearch.tpl"}
			<form id="formDelitos" method="POST" action="delitos.php" class="list">
				<input type="hidden" name="action" id="action">
				<input type="hidden" name="s" id="s" value="{$seccional}">
				<input type="hidden" name="id" id="id" />
				<table class="table1">
					<tr>
						<th><a href="#" onclick="ordenar('Fecha','formDelitosSearch')"><img id="sortFecha" class="sortImage" src="images/sort_desc.png">Fecha</a></th>
						{if $seccional!=2}
							<th><a href="#" onclick="ordenar('Barrio','formDelitosSearch')"><img id="sortBarrio" class="sortImage" src="images/sort_both.png">Barrio</a></th>
						{/if}
						<th><a href="#" onclick="ordenar('Tipodelito','formDelitosSearch')"><img id="sortTipodelito" class="sortImage" src="images/sort_both.png">Delito</a></th>
						<th><a href="#" onclick="ordenar('Denunciante_nombre','formDelitosSearch')"><img id="sortDenunciante_nombre" class="sortImage" src="images/sort_both.png">Denunciante</a></th>
						<th><a href="#" onclick="ordenar('Nombre','formDelitosSearch')"><img id="sortNombre" class="sortImage" src="images/sort_both.png">Imputado</a></th>
						<th><a href="#" onclick="ordenar('Victima_nombre','formDelitosSearch')"><img id="sortVictima_nombre" class="sortImage" src="images/sort_both.png">Victima</a></th>
						{if $seccional==3}<!-- Solo para Delito Mujer -->
							<th><a href="#" onclick="ordenar('vto_cautelar','formDelitosSearch')"><img id="sortVto_Cautelar" class="sortImage" src="images/sort_both.png">Vto. Cautelar</a></th>
						{/if}
						
						<th>&nbsp;</th>
					</tr>
					
					{foreach from=$delitos item=delito}
						<tr class="odd gradeX">
							<td class="item">{$delito.fecha|date_format:'%d-%m-%Y'}</td>
							{if $seccional!=2}
								<td class="item">{$delito.barrio}</td>
							{/if}
							<td class="item">{$delito.tipodelito}</td>
							<td class="item">{$delito.denunciante_nombre}</td>
							<td class="item">{$delito.nombre}</td>
							<td class="item">{$delito.victima_nombre}</td>
							{if $seccional==3}
								{if $smarty.now|date_format:"%Y-%m-%d" > $delito.vto_cautelar|date_format:"%Y-%m-%d"}
								    <td style="color:red" class="item">
								         {if $delito.vto_cautelar != '0000-00-00'}
								              {$delito.vto_cautelar|date_format:"%d-%m-%Y"}
								         {/if}
								    </td>
								{else}
								    <td class="item">
								         {if $delito.vto_cautelar != '0000-00-00'}
								              {$delito.vto_cautelar|date_format:"%d-%m-%Y "}
								         {/if}
								    </td>
								{/if}
														
<!--								<td style="color:red" class="item">{$delito.vto_cautelar}</td>-->
							{/if}
							<td valign="middle" style="padding-top:4px;"class="item" align="right">
								<a href="delitos.php?action=details&s={$seccional}&id={$delito.id}"  ><img width="25px" src="images/b_details.png" alt="Detalle" title="Detalle" style="padding-right:7px"/></a>
								{if $rol|strpos:"0" !== false || ($rol|strpos:"Ew" !== false && $seccional == 1) || ($rol|strpos:"Pw" !== false && $seccional == 2) || ($rol|strpos:"Mw" !== false && $seccional == 3) || ($rol|strpos:"Cw" !== false && $seccional == 4) }
								<a href="delitos.php?action=update&s={$seccional}&id={$delito.id}" ><img width="25px" src="images/b_edit2.png" alt="Editar" title="Editar" style="padding-right:7px"/></a>
								<a href="#" onclick="deleteRecord({$delito.id},'formDelitos')" ><img width="25px" src="images/b_remove.png" alt="Borrar" title="Borrar" style="padding-right:7px"/></a>
								{/if}
							</td>
						</tr>
					{/foreach}
				</table>
				{include file="paginator.tpl" page=$page totalPages=$totalPages script="delitos.php?$allParams"}
			</form>
		</div>
	</div>
</div>